package org.springblade.modules.admin.task;

import cn.hutool.core.date.DateUtil;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springblade.modules.admin.enums.MaintainPlanContentEnum;
import org.springblade.modules.admin.service.IMaintainPlanDayCountService;
import org.springblade.modules.admin.service.IMaintainPlanWeeklyReportService;
import org.springblade.modules.admin.service.IMaintainSignService;
import org.springblade.modules.admin.service.MaintainPlanUserDayCountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * @Date 15:07 2022/7/26
 * @Description {
 * 工单每天
 * }
 * @Author lsay
 **/
@Component
public class PlanDayCountJob {

	@Autowired
	private IMaintainPlanDayCountService planDayCountService;
	@Autowired
	private IMaintainPlanWeeklyReportService planWeeklyReportService;
	/**
	 * 每天 02:00 统计所有工单
	 */
	//@Scheduled(cron = "0 0 2 * * ?")
	@XxlJob(value = "planDayCount")
	public void planUserDayCount() {
		XxlJobHelper.handleSuccess("统计所有工单-(planDayCount)-[执行]开始");

		try {
			planDayCountService.updateWxRescuePlanDayCount();

			String weekDateEnum = DateUtil.thisDayOfWeekEnum().name();
			if("MONDAY".equals(weekDateEnum)){
				planWeeklyReportService.generatePlanWeeklyReport(null,null);
			}
			XxlJobHelper.handleSuccess("统计所有工单-(planDayCount)-[执行]成功");
		} catch (Exception e) {
			XxlJobHelper.handleSuccess("统计所有工单-(planDayCount)-[执行]失败" + e);
		}
	}

}
